<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>AES加密解密</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://shc0743.github.io/crypto-js/core.js"></script>
<script src="https://shc0743.github.io/crypto-js/enc-base64.js"></script>
<script src="https://shc0743.github.io/crypto-js/enc-hex.js"></script>
<script src="https://shc0743.github.io/crypto-js/enc-utf8.js"></script>
<script src="https://shc0743.github.io/crypto-js/enc-utf16.js"></script>
<script src="https://shc0743.github.io/crypto-js/crypto-js.js"></script>
<script src="https://shc0743.github.io/crypto-js/aes.js"></script>
<script src="https://shc0743.github.io/crypto-js/md5.js"></script>
<script src="https://shc0743.github.io/crypto-js/sha1.js"></script>
<script src="https://shc0743.github.io/crypto-js/sha512.js"></script>
<script src="https://shc7432.github.io/public/something/sometool.js"></script>
  <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script src="https://shc7432.github.io/public/getLinkInput/getLinkInput.js"></script>
</head>
<body>
<h1>AES加密解密</h1>
<form id="frm1" style="border:1px solid #ccc;">
输入密码<input id=keypw placeholder=请输入密码><br>
要加密/解密的内容<textarea id=ctet1 placeholder=请输入内容 cols=50 rows=5></textarea><br>
<button type="button" onclick="addpw()">加密</button><button type="button" onclick="unaddpw()">解密</button>
</form>
<div class="pwout" title="加密结果">
加密结果:<textarea id=pwout1 cols=50 rows=5 readonly></textarea>
</div>
<div class="pwout2" title="解密结果">
解密结果:<textarea id=pwout3 cols=50 rows=5 readonly></textarea>
</div>

<script>
$(function(){

$(".pwout").dialog({
autoOpen: false,
modal: true,
buttons: {
"确定": function(){
$(this).dialog("close");
}
 }
})

$(".pwout2").dialog({
autoOpen: false,
modal: true,
buttons: {
"确定": function(){
$(this).dialog("close");
}
})

window.addpw=function(){
    var pwd = keypw.value;
    var str=ctet1.value
    var mi = CryptoJS.AES.encrypt(str, pwd);
    pwout1.value=mi;
    $(".pwout").dialog("open");
}
window.unaddpw=function(){
    var result = CryptoJS.AES.decrypt(ctet1.value, keypw.value).toString(CryptoJS.enc.Utf8);
    pwout3.value=result;
    $(".pwout2").dialog("open");
}
})
</script>
</body>
</html>
